//
//  YKQueue.c
//  ProjectM
//
//  Created by gaofeng on 2021/5/12.
//

#include "YKQueue.h"

void initQueue(SqQueue *Q){
    Q->front = 0;
    Q->rear = 0;
}
int isEmpty(SqQueue Q){
    if (Q.front ==Q.rear) {
        return 1;
    }else{
        return 0;
    }
}
int EnQueue(SqQueue *Q,int x){
    if ((Q->rear+1)%kMaxQueueLen==Q->front) {
        return 1;//!> 堆满
    }
    Q->data[Q->rear] = x;
    Q->rear = (Q->rear+1)%kMaxQueueLen;
    return 0;
}
int DeQueue(SqQueue *Q,int *x){
    if (Q->front == Q->rear) {
        return 1; //!> 堆空
    }
    *x = Q->data[Q->front];
    Q->front = (Q->front+1)%kMaxQueueLen;
    return 0;
}

void initPQueue(SPQueue Q){
    Q->front = 0;
    Q->rear = 0;
}
int isPEmpty(SPQueue Q){
    if (Q->front ==Q->rear) {
        return 1;
    }else{
        return 0;
    }
}
int EnPQueue(SPQueue Q,BiTree x){
    if ((Q->rear+1)%kMaxQueueLen==Q->front) {
        return 1;//!> 堆满
    }
    Q->data[Q->rear] = x;
    Q->rear = (Q->rear+1)%kMaxQueueLen;
    return 0;
}
int DePQueue(SPQueue Q,BiTree *x){
    if (Q->front == Q->rear) {
        return 1; //!> 堆空
    }
    *x = Q->data[Q->front];
    Q->front = (Q->front+1)%kMaxQueueLen;
    return 0;
}
